<?php

// 操作私人定制状态
// PUT ctrl.self.status
// http://sg.io/api?ctrl.self.status

namespace app\api\resource\ctrl\self;
use think\Db;

class Status
{
    // 方法
    public $_method = ['PUT'];
    // 前置
    public $_pre    = [];
    // public $_pre    = ['member'];
    // 描述
    public $_description = '操作私人定制状态';
    // 参数
    public $_param  = [
        'id'     => '主键',
        'status' => '状态,默认全部,0-待受理 1-已受理 2-已完结 9-废弃',
    ];

    public function run(&$request)
    {
        $id     = $request->param('id/d',0);
        $status = $request->param('status/d',-1);
        
        if (0 == $id)      return [422,'主键必需'];
        if (-1 == $status) return [422,'状态必需'];

        $num = Db::name('self_form')->where('id',$id)->update(['status'=>$status]);

        return ($num > 0) ? [201,'操作成功'] : [500,'操作失败'];
    }
}
